package com.mryan.server_project.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

/**
 * @BelongsProject: ps_cloud
 * @BelongsPackage: com.mryan.server_project.controller
 * @Author: Yan
 * @CreateTime: 2021-04-25 19:21
 * @Description:
 */
@RestController
public class TestController {

	@GetMapping("test1")
	@PreAuthorize("hasAnyAuthority('user:add')")
	public String test1(){
		return "拥有'user:add'权限";
	}

	@GetMapping("test2")
	@PreAuthorize("hasAnyAuthority('user:update')")
	public String test2(){
		return "拥有'user:update'权限";
	}

	@GetMapping("user")
	public Principal currentUser(Principal principal) {
		return principal;
	}
}
